<template>
  <div class="fp-aside-container">
    <div class="fp-aside-body">
      <fp-aside-button v-for="(item) in items"
                       :key="item.id"
                       :activated.sync="item.activated"
                       :icon="item.icon"
                       :text="item.text"
                       :type="item.type"
                       :link="item.link"
                       :id="item.id"
                       :extend="item.extend"
                       :badge="item.badge"
                       @changeState="changeState(item)"/>
    </div>
  </div>
</template>

<script>
import FpAsideButton from "./FpAsideButton";
import {mapState, mapActions} from 'vuex'

export default {
  name: "FpAside",
  components: {FpAsideButton},
  computed: {
    ...mapState({
      items: state => state.aside.items,
      activeId: state => state.aside.activeId,
    })
  },
  created() {
    this.getItems()
  },
  methods: {
    ...mapActions({
      'getItems': 'aside/getItems',
      'setActiveItem': 'aside/setActiveItem',
      'setDebug': 'editor/setDebug'
    }),
    changeState(playload) {
      if (playload.icon === 'debug') {
        this.setDebug(true)
      }
      if (playload.extend) {
        this.setActiveItem(playload)
      }
    }
  }
}
</script>

<style scoped>

.fp-aside-container {
  position: absolute;
  top: 55px;
  width: 65px;
  padding-top: 6px;
  bottom: 0;
  background-color: #fff;
  z-index: 4;
}

.fp-aside-body {
  display: flex;
  flex-direction: column;
}

</style>
